package com.youlu.campus.admin.platform;

import com.youlu.campus.entity.PointPlatformConfig;
import com.youlu.campus.entity.PointPlatformConfigQueryVO;
import com.youlu.campus.service.platform.PointPlatformConfigService;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * 积分平台配置
 */
@RestController
public class PointPlatformConfigController {
    @Autowired
    private PointPlatformConfigService pointPlatformConfigService;

    /**
     * 积分平台配置
     *
     * @return
     */
    @GetMapping("/point/platform-config")
    public QResult getPlatformConfig() {
        return QResult.success(pointPlatformConfigService.find());
    }

    /**
     * 积分平台配置修改
     *
     * @return
     */
    @PostMapping("/point/platform-config/update")
    public QResult updatePlatformConfig(@RequestBody PointPlatformConfig config) {
        return QResult.success(pointPlatformConfigService.update(config));
    }

    @PostMapping("/point/platform-config/create")
    public QResult createPlatformConfig(@RequestBody @NotNull PointPlatformConfig config) {
        return QResult.success(pointPlatformConfigService.create(config));
    }

    @PostMapping("/point/platform-config/list")
    public QResult list(@RequestBody @NotNull PointPlatformConfigQueryVO req) {
        return QResult.success(pointPlatformConfigService.list(req));
    }

    @PostMapping("/point/platform-config/delete")
    public QResult delete(@RequestParam("id") String id) {
        return QResult.success(pointPlatformConfigService.delete(id));
    }

    @GetMapping("/point/platform-config/find-one")
    public QResult findOne(@RequestParam("id") String id) {
        return QResult.success(pointPlatformConfigService.findOne(id));
    }
}
